using System;
using System.Data;
using System.Collections;

namespace APP.QUANLY.Entity
{
    /// <summary>
    /// Summary description for NGUOIDUNG.
    /// </summary>
    public class NGUOIDUNGList : CollectionBase
    {
        private string _ErrMsg;
        public string ErrMsg { get { return _ErrMsg; } }
        public NGUOIDUNGList()
        {
        }

        public void Add(NGUOIDUNG entity)
        {
            this.List.Add(entity);
        }

        public void Add(NGUOIDUNGList list)
        {
            foreach (NGUOIDUNG entity in list)
            {
                this.Add(entity);
            }
        }

        public new virtual Enumerator GetEnumerator()
        {
            return new Enumerator(this);
        }
        public virtual NGUOIDUNG this[int index]
        {
            get
            {
                return (NGUOIDUNG)this.List[index];
            }
            set
            {
                this.List[index] = value;
            }
        }

        #region Find Object And List Object
        //---PrimaryKey
        public virtual NGUOIDUNG Find(string MANGUOIDUNG)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.MANGUOIDUNG.ToString().ToUpper().Trim() == MANGUOIDUNG.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNGList FindListByMANGUOIDUNG(string MANGUOIDUNG)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.MANGUOIDUNG.ToString().ToUpper().Trim() == MANGUOIDUNG.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }
        //---NonPrimaryKey
        public virtual NGUOIDUNG FindByMANHANVIEN(Int32 MANHANVIEN)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.MANHANVIEN.ToString().ToUpper().Trim() == MANHANVIEN.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNG FindByTENNGUOIDUNG(string TENNGUOIDUNG)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.TENNGUOIDUNG.ToString().ToUpper().Trim() == TENNGUOIDUNG.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNG FindByTENDANGNHAP(string TENDANGNHAP)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.TENDANGNHAP.ToString().ToUpper().Trim() == TENDANGNHAP.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNG FindByMATKHAU(string MATKHAU)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.MATKHAU.ToString().ToUpper().Trim() == MATKHAU.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNG FindByISDELETE(bool ISDELETE)
        {
            foreach (NGUOIDUNG obj in this.List)
            {
                if (obj.ISDELETE.ToString().ToUpper().Trim() == ISDELETE.ToString().ToUpper().Trim())
                {
                    obj.IsExisting = true;
                    return obj;
                }
            }
            return null;
        }

        public virtual NGUOIDUNGList FindListByMANHANVIEN(Int32 MANHANVIEN)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.MANHANVIEN.ToString().ToUpper().Trim() == MANHANVIEN.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }


        public virtual NGUOIDUNGList FindListByTENNGUOIDUNG(string TENNGUOIDUNG)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.TENNGUOIDUNG.ToString().ToUpper().Trim() == TENNGUOIDUNG.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }


        public virtual NGUOIDUNGList FindListByTENDANGNHAP(string TENDANGNHAP)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.TENDANGNHAP.ToString().ToUpper().Trim() == TENDANGNHAP.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }


        public virtual NGUOIDUNGList FindListByMATKHAU(string MATKHAU)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.MATKHAU.ToString().ToUpper().Trim() == MATKHAU.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }


        public virtual NGUOIDUNGList FindListByISDELETE(bool ISDELETE)
        {
            try
            {
                NGUOIDUNGList List = new NGUOIDUNGList();
                foreach (NGUOIDUNG obj in this.List)
                {
                    if (obj.ISDELETE.ToString().ToUpper().Trim() == ISDELETE.ToString().ToUpper().Trim())
                    {
                        List.Add(obj);
                    }
                }
                if (List.Count > 0) return List;
                else return null;
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                return null;
            }
        }
        #endregion

        #region Inner Classes
        /// <summary>
        /// Type-specific enumeration class, used by LogCollection.GetEnumerator.
        /// </summary>
        public class Enumerator : IEnumerator
        {
            private IEnumerator wrapped;

            public Enumerator(NGUOIDUNGList collection)
            {
                this.wrapped = ((CollectionBase)collection).GetEnumerator();
            }

            public NGUOIDUNG Current
            {
                get
                {
                    return (NGUOIDUNG)(this.wrapped.Current);
                }
            }

            object IEnumerator.Current
            {
                get
                {
                    return (NGUOIDUNG)(this.wrapped.Current);
                }
            }

            public bool MoveNext()
            {
                return this.wrapped.MoveNext();
            }

            public void Reset()
            {
                this.wrapped.Reset();
            }
        }
        #endregion
    }
}